<?php
// +----------------------------------------------------------------------
// | EasyAdmin
// +----------------------------------------------------------------------
// | PHP交流群: 763822524
// +----------------------------------------------------------------------
// | 开源协议  https://mit-license.org 
// +----------------------------------------------------------------------
// | github开源项目：https://github.com/zhongshaofa/EasyAdmin
// +----------------------------------------------------------------------
namespace app\model\api;

use laytp\BaseModel;
use think\model\concern\SoftDelete;

class SkySeasonCandle extends BaseModel
{
    protected $name = 'sky_season_candle';


    /**
     * 大蜡烛详情
     * @param $season
     * @return array
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function detail($season){
        $detail = $this->where('season','=',$season)->cache(true)->find()->toArray();

        $candle_info = [];
        for($i=1;$i<=5;$i++){
            $content1 = json_decode($detail['area'.$i.'_content1'],true);
            $content2 = json_decode($detail['area'.$i.'_content2'],true);

            $candle_info[] = array(
                'area' => $detail['area'.$i],
                'position' => array(
                    array(
                        'img' => $content1
                    ),
                    array(
                        'img' => $content2
                    )
                )
            );
        }
        
        $return = array(
            'name' => $season,
            'list' => $candle_info,
        );
        return $return;
    }
}